package com.baizan.daka.ui.presenter

import com.baizan.daka.base.BasePresenter
import com.baizan.daka.mvp.model.MeModel
import com.baizan.daka.ui.contract.LoginContract
import com.baizan.daka.mvp.model.UserModel
import com.baizan.daka.mvp.model.bean.LoginInfoBean
import com.baizan.daka.rx.Subscriber.CommonSubscriber
import com.baizan.daka.showToast
import com.baizan.daka.ui.contract.ModifyPasswordContract
import com.baizan.daka.ui.contract.ShowCashDesContract
import com.baizan.daka.util.Md5

class ShowCashDesPresenter(val mView: ShowCashDesContract.View) : BasePresenter(),
    ShowCashDesContract.Presenter {


    private val meModel: MeModel by lazy {
        MeModel()
    }

    override fun cashOut(amount: String,password:String) {
        mView.showLoadingDialog()

        meModel.applyShowCash(amount,Md5.getPasswordMd5(password))
            .subscribe(object : CommonSubscriber<Any>(compositeDisposable) {
                override fun onCallNext(t: Any?) {
                    mView.cashOutSuccess()
                }

                override fun onCallCompleted() {
                    super.onCallCompleted()
                    mView.hideLoadingDialog()
                }

                override fun onCallError(e: String) {
                    super.onCallError(e)
                    showToast(e)
                }
            })
    }


}

